package com.ruoyi.mhrb.cases.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.mhrb.cases.domain.MhrbCaseLists;
import com.ruoyi.mhrb.cases.service.IMhrbCaseListsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 案例列表Controller
 *
 * @author jhrb
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/mhrb/cases/caseLists")
public class MhrbCaseListsController extends BaseController {
    @Autowired
    private IMhrbCaseListsService mhrbCaseListsService;

    /**
     * 查询案例列表列表
     */
    @PreAuthorize("@ss.hasPermi('mhrb:cases:caseLists:list')")
    @GetMapping("/list")
    public TableDataInfo list(MhrbCaseLists mhrbCaseLists) {
        startPage();
        List<MhrbCaseLists> list = mhrbCaseListsService.selectMhrbCaseListsList(mhrbCaseLists);
        return getDataTable(list);
    }

    /**
     * 导出案例列表列表
     */
    @PreAuthorize("@ss.hasPermi('mhrb:cases:caseLists:export')")
    @Log(title = "案例列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MhrbCaseLists mhrbCaseLists) {
        List<MhrbCaseLists> list = mhrbCaseListsService.selectMhrbCaseListsList(mhrbCaseLists);
        ExcelUtil<MhrbCaseLists> util = new ExcelUtil<MhrbCaseLists>(MhrbCaseLists.class);
        util.exportExcel(response, list, "案例列表数据");
    }

    /**
     * 获取案例列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('mhrb:cases:caseLists:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mhrbCaseListsService.selectMhrbCaseListsById(id));
    }

    /**
     * 新增案例列表
     */
    @PreAuthorize("@ss.hasPermi('mhrb:cases:caseLists:add')")
    @Log(title = "案例列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MhrbCaseLists mhrbCaseLists) {
        return toAjax(mhrbCaseListsService.insertMhrbCaseLists(mhrbCaseLists));
    }

    /**
     * 修改案例列表
     */
    @PreAuthorize("@ss.hasPermi('mhrb:cases:caseLists:edit')")
    @Log(title = "案例列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MhrbCaseLists mhrbCaseLists) {
        return toAjax(mhrbCaseListsService.updateMhrbCaseLists(mhrbCaseLists));
    }

    /**
     * 删除案例列表
     */
    @PreAuthorize("@ss.hasPermi('mhrb:cases:caseLists:remove')")
    @Log(title = "案例列表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mhrbCaseListsService.deleteMhrbCaseListsByIds(ids));
    }
}
